package com.borrower.action;

import com.borrower.dto.BorrowInfoBean;
import com.borrower.service.BorrowerServiceImpl;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

/**
 * 显示用户模块借书信息列表
 */
public class BorrowInfoAction extends Action{
    @Override
    public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PrintWriter out = response.getWriter();
        BorrowerServiceImpl service = new BorrowerServiceImpl();
        HttpSession session = request.getSession();
        String loginName = String.valueOf(session.getAttribute("loginName"));
        List<BorrowInfoBean> list = service.BorrowInfoService(loginName);

        Gson gson = new Gson();
        String str = gson.toJson(list);

        out.print(str);

    }
}
